﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PacManLib;

namespace PacManAI_SampleAI
{
    /// <summary>
    /// An abstract base class, to check that we can still find
    /// the derived class correctly.
    /// </summary>
    public abstract class GhostsBase : IGhostAI
    {
        #region Abstract methods

        public abstract string getAIName_Implementation();
        public abstract string getCodersName_Implementation();
        public abstract PlayerInfo.Direction getDesiredDirection_Implementation(Board board, PlayerInfo ghostInfo);

        #endregion

        #region IGhostAI Members

        public string getAIName()
        {
            return getAIName_Implementation();
        }

        public string getCodersName()
        {
            return getCodersName_Implementation();
        }

        public PlayerInfo.Direction getDesiredDirection(Board board, PlayerInfo ghostInfo)
        {
            return getDesiredDirection_Implementation(board, ghostInfo);
        }

        #endregion
    }

    /// <summary>
    /// Ghosts that move randomly.
    /// </summary>
    public class Ghosts : GhostsBase
    {
        #region IGhostAI Members

        /// <summary>
        /// Returns the nickname for this AI.
        /// </summary>
        public override string getAIName_Implementation()
        {
            return "Random ghosts";
        }

        /// <summary>
        /// Returns the coder's name.
        /// </summary>
        public override string getCodersName_Implementation()
        {
            return "Richard Shepherd";
        }

        /// <summary>
        /// Returns the direction for the ghosts to move.
        /// </summary>
        public override PlayerInfo.Direction getDesiredDirection_Implementation(Board board, PlayerInfo ghostInfo)
        {
            return (PlayerInfo.Direction)m_rnd.Next(0, 4);
        }

        #endregion

        #region Private data

        // Random number generator for ghost movement...
        private static int m_seed = 1;
        private Random m_rnd = new Random(m_seed++);

        #endregion
    }
}
